package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Salary;
import cn.wolfcode.mapper.SalaryMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.ISalaryService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SalaryServiceImpl implements ISalaryService {
    @Autowired
    private SalaryMapper salaryMapper;

    public PageInfo<Salary> selectForList(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<Salary> salaries = salaryMapper.selectForList(qo);
        return new PageInfo<>(salaries);
    }

    @Override
    public Salary selectOne(Long id) {
        Salary salary = salaryMapper.selectByPrimaryKey(id);
        return salary;
    }

    @Override
    public void updateByPrimaryKey(Salary salary) {
        //修改工资
        salaryMapper.updateByPrimaryKey(salary);
    }

    @Override
    public void insert(Salary salary) {
        salaryMapper.insert(salary);
    }
}
